p(__int128_t z){if(z>=10)p(z/10);printf("%d",z%10);}
__int128_t f(a,n){__int128_t z=1;for(;n--;z*=a);return z;}
a[64];main(i,w)
{
	unsigned long long n;
	for(;~scanf("%llu",&n)&&n;puts("}"))
	{	
		printf("{ ");
		for(w=0,i=1,--n;n;i++)
			if(f(2,i)-1>=n)
				n-=f(2,i-1),a[w++]=i-1,i=0;

		for(;w--;printf(w?", ":" "))
			p(f(3,a[w]));
	}
}
